import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:flutter_demo/demo/bottom_sheet_demo.dart';
import 'package:flutter_demo/demo/button_demo.dart';
import 'package:flutter_demo/demo/checkbox_demo.dart';
import 'package:flutter_demo/demo/chip_demo.dart';
import 'package:flutter_demo/demo/data_table_demo.dart';
import 'package:flutter_demo/demo/date_time_demo.dart';
import 'package:flutter_demo/demo/popup_menu_button_demo.dart';
import 'package:flutter_demo/demo/radio_demo.dart';
import 'package:flutter_demo/demo/simple_dialog_demo.dart';
import 'package:flutter_demo/demo/slider_demo.dart';
import 'package:flutter_demo/demo/snack_bar_demo.dart';
import 'package:flutter_demo/demo/stepper_demo.dart';
import 'package:flutter_demo/demo/switch_demo.dart';

import 'alert_dialog_demo.dart';
import 'card_demo.dart';
import 'expansion_panel_demo.dart';

class MaterialCompinents extends StatelessWidget {
  MaterialCompinents({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('MaterialCompinents'),
        elevation: 0.0,
      ),
      body: ListView(
        children: [
          ListItem(
              title: 'FloatingActionButton', page: FloatingActionButtonDemo()),
          ListItem(title: 'ButtonDemo', page: ButtonDemo()),
          ListItem(title: 'PopupMenuButtonDemo', page: PopupMenuButtonDemo()),
          ListItem(title: 'CheckBoxDemo', page: CheckBoxDemo()),
          ListItem(title: 'RadioDemo', page: RadioDemo()),
          ListItem(title: 'SwitchDemo', page: SwitchDemo()),
          ListItem(title: 'SliderDemo', page: SliderDemo()),
          ListItem(title: 'DateTimeDemo', page: DateTimeDemo()),
          ListItem(title: 'SimpleDialogDemo', page: SimpleDialogDemo()),
          ListItem(title: 'AlertDialogDemo', page: AlertDialogDemo()),
          ListItem(title: 'BottomSheetDemo', page: BottomSheetDemo()),
          ListItem(title: 'SnackBarDemo', page: SnackBarDemo()),
          ListItem(title: 'ExpansionPanelDemo', page: ExpansionPanelDemo()),
          ListItem(title: 'ChipDemo', page: ChipDemo()),
          ListItem(title: 'DataTableDemo', page: DataTableDemo()),
          ListItem(title: 'CardDemo', page: CardDemo()),
          ListItem(title: 'StepDemo', page: StepDemo())
        ],
      ),
    );
  }
}



class WidgetDemo extends StatelessWidget {
  const WidgetDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('WidgetDemo'),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [],
            )
          ],
        ),
      ),
    );
  }
}

class FloatingActionButtonDemo extends StatelessWidget {
  const FloatingActionButtonDemo({super.key});

  @override
  Widget build(BuildContext context) {
    final Widget _floatingActionButton = FloatingActionButton(
      onPressed: () {},
      child: Icon(
        Icons.add,
        color: Colors.white,
      ),
      elevation: 0.0,
      backgroundColor: Colors.black87,
      // shape: BeveledRectangleBorder(
      //   borderRadius: BorderRadius.circular(30.0)
      // ),
    );

    final Widget _floatingActionButtonExtended = FloatingActionButton.extended(
      onPressed: () {},
      icon: Icon(Icons.add),
      label: Text('Add'),
    );

    return Scaffold(
      appBar: AppBar(
        title: Text('FloatingActionButtonDemo'),
        elevation: 0.0,
      ),
      floatingActionButton: _floatingActionButton,
      floatingActionButtonLocation:
          FloatingActionButtonLocation.centerDocked, //悬浮居中
      bottomNavigationBar: BottomAppBar(
        //底部 导航
        child: Container(
          height: 80.0,
        ),
        shape: CircularNotchedRectangle(), //圆形带缺口形状
      ),
    );
  }
}

class ListItem extends StatelessWidget {
  final String title;
  final Widget page;
  ListItem({required this.title, required this.page});

  @override
  Widget build(BuildContext context) {
    return ListTile(
      title: Text(title),
      onTap: () {
        Navigator.of(context)
            .push(MaterialPageRoute(builder: (context) => page));
      },
    );
  }
}
